<?php

namespace App\Http\Common\nacos;

use App\Http\Common\nacos\service\NamespaceService;

abstract class NacosConfig
{
    /**
     * @var string
     */
    protected $host;

    /**
     * @var string
     */
    protected $path;

    /**
     * @var string
     */
    protected $dataId;

    /**
     * @param string $dataId
     */
    public function setDataId(string $dataId): self
    {
        $this->dataId = $dataId;
        return $this;
    }

    /**
     * @return string
     */
    public function getDataId(): string
    {
        return $this->dataId;
    }

    /**
     * @var string
     */
    protected $group;

    /**
     * @param string $group
     */
    public function setGroup(string $group): self
    {
        $this->group = $group;
        return $this;
    }

    /**
     * @return string
     */
    public function getGroup(): string
    {
        return $this->group;
    }

    /**
     * @var string
     */
    protected $tenant;

    /**
     * @return string
     */
    public function getTenant(): string
    {
        return $this->tenant;
    }

    /**
     * @param string $tenant
     */
    public function setTenant(string $tenant): self
    {
        $this->tenant = $tenant;
        return $this;
    }

    /**
     * @var string
     */
    protected $url;

    /**
     * @var string
     */
    protected $content;

    public function __construct()
    {
        $this->url = config('services.nacos.host') . $this->path;
    }

    /**
     * @return string
     */
    public abstract function get(): string;

    public function setConfig($class, $arguments)
    {
        call_user_func_array([$class, 'set'], [$arguments]);
    }
}
